package final_wearebatman_view;

import final_wearebatman_model.AND_Gate;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;


//az és kaput megjelenítő osztály
public class AND_GateView implements Ipaintable {

    private AND_Gate andgate;
    private CircuitView circuitview;
    private int posX; //x koordináta
    private int posY; //y koordináta
    private int angle; //forgatási szög
    private String name; //név

    //konstruktor
    public AND_GateView(AND_Gate ag, String name, CircuitView cv, int pX, int pY, int a) {
        this.andgate = ag;
        this.circuitview = cv;
        this.posX = pX;
        this.posY = pY;
        this.angle = a;
        this.name = name;
    }

    //rajzolás
    public void paint(Graphics2D g) {
        AffineTransform aT = g.getTransform();
        g.translate(posX, posY);
        g.rotate(this.angle * Math.PI / 180);
        g.drawLine(0, 6, 8, 6);
        g.drawLine(0, 23, 8, 23);
        g.drawLine(8, 1, 8, 28);
        g.drawLine(8, 1, 25, 1);
        g.drawLine(8, 28, 25, 28);
        g.drawArc(11, 1, 28, 27, -90, 180);
        g.drawLine(39, 15, 47, 15);
        g.setTransform(aT);
    }

    //x koordináta lekérése
    public int getPosX() {
        return this.posX;
    }

    //y koordináta lekérése
    public int getPosY() {
        return this.posY;
    }

    //forgatási szög lekérése
    public int getAngle() {
        return this.angle;
    }

    //inputok helye
    public Point getInputPinPosition(int id) {
        if (id == 0) {
            return new Point(posX + 0, posY + 6);
        } else {
            return new Point(posX + 0, posY + 23);
        }
    }

    //output helye
    public Point getOutputPinPosition(int id) {
        return new Point(posX + 47, posY + 15);
    }

    public Rectangle getClickArea() {
        return new Rectangle();
    }

    public void onClick() {

    }
}
